package com.example.hxds.odr.config;

/**
 * @Author XUYANG
 * @Date 2024-03-22 14:36
 */

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;

import javax.annotation.Resource;

@Configuration
public class RedisConfiguration {
    @Resource
    private RedisConnectionFactory connectionFactory;
    @Bean
    public ChannelTopic expiredTopic(){
        //创建Redis队列，当有字段删除时会往这个队列中发送消息
        return new ChannelTopic("delete_bill_order");
    }
    @Bean
    public RedisMessageListenerContainer redisMessageListenerContainer(){
        RedisMessageListenerContainer redisMessageListenerContainer=new RedisMessageListenerContainer();
        redisMessageListenerContainer.setConnectionFactory(connectionFactory);
        return redisMessageListenerContainer;
    }
}
